let appName = 'dianxiaotong-';
let objectTag = '*isObjectValue*';
let ls = {
  setItem(name, value) {
    let localName = appName + name;
    if (typeof value == 'object') {
      value = JSON.stringify(value) + objectTag;
    }
    localStorage.setItem(localName, value);
  },
  getItem(name) {
    let localName = appName + name;
    let value = localStorage.getItem(localName) || '';
    if (value.indexOf(objectTag) > -1) {
      value = JSON.parse(value.replace(objectTag, ''));
    };
    return value;
  },
  removeItem(name) {
    let localName = appName + name;
    localStorage.removeItem(localName);
  },
  clear() {
    localStorage.clear();
  }
};

export default ls;